﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RLGDashboard
{
    static class ArrayExtension
    {
        public static T[] addItemToArray<T>(this T[] original, T itemToAdd)
        {
            T[] finalArray = new T[original.Length + 1];

            for (int i = 0; i < original.Length; i++)
            {
                finalArray[i] = original[i];
            }

            finalArray[finalArray.Length - 1] = itemToAdd;
            return finalArray;
        }

        public static T[] removeItemFromArray<T>(this T[] original, Int32 index)
        {
            T[] finalArray = new T[original.Length - 1];
            int wantedIndex = 0;
            for (int i = 0; i < original.Length; i++)
            {
                if (i != index)
                {
                    finalArray[wantedIndex] = original[i];
                    wantedIndex++;
                }
            }
            return finalArray;
        }
    }
}
